//
//  UILabel+Extension.swift
//  WeiBo_Private
//
//  Created by Yangperlove on 16/1/18.
//  Copyright © 2016年 Yangperlove. All rights reserved.
//

import UIKit

extension UILabel {
    //工厂方法
    class func factoryCreatLabel(title: String, color: UIColor, fontSize: CGFloat) -> UILabel{
        let lab = UILabel()
        lab.text = title
        lab.textColor = color
        lab.textAlignment = .Center
        lab.numberOfLines = 0
        lab.font = UIFont.systemFontOfSize(fontSize)
        lab.sizeToFit()
        return lab
    }
    
    //便利构造方法
    convenience init(title: String? = "", color: UIColor, fontSize: CGFloat, margin: CGFloat = 0) {
        self.init()
        text = title
        textColor = color
        textAlignment = .Center
        if margin > 0 {
            textAlignment = .Left
            preferredMaxLayoutWidth = screenSize.width - 2 * kStatusCellMargin
        }
        numberOfLines = 0
        font = UIFont.systemFontOfSize(fontSize)
        sizeToFit()
    }
    
}
